/****************************************************
 *  Copyright © 2023-2030 CaiTao. All rights reserved.
 *------------------------------------------------------------------------
 *  文件：TouchManager.cs
 *  作者：CT
 *  日期：Created by Fxb on 2023/5/30 10:38:7
 *  项目：混合动力发动机试验系统
 *  功能：Nothing
*****************************************************/

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TouchInputManager
{
    /*
     Single Finger X
     Single Finger Y
     Multi Finger
     */

    /// <summary>
    /// 多指操作管理器
    /// </summary>
    public class TouchManager
    {
        public SingleFingerXTouch fingerXTouch = new SingleFingerXTouch();
        public SingleFingerYTouch fingerYTouch = new SingleFingerYTouch();
        public MultiFingerTouch multiFingerTouch = new MultiFingerTouch();
        public ClickTouch clickTouch = new ClickTouch();

        private static TouchManager instance;
        public static TouchManager Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new TouchManager();
                }
                return instance;
            }
        }

        public void ClickCheck()
        {
            clickTouch.ClickCheck();
        }

        public virtual float GetTouchInput(string AxisName)
        {
            float input = 0;

            if (Input.touchCount <= 0)
            {
                return 0;
            }

            for (int i = 0; i < Input.touchCount; i++)
            {
                if (AxisName == "Mouse X")
                {
                    if( fingerXTouch.TouchSelect(i))
                        input = fingerXTouch.TouchUpdateValue();
                }

                if (AxisName == "Mouse Y")
                {
                    if(fingerYTouch.TouchSelect(i))
                        input = fingerYTouch.TouchUpdateValue();
                }

                if (AxisName == "Multi Finger")
                {
                    if( multiFingerTouch.TouchSelect(i))
                        input = multiFingerTouch.TouchUpdateValue();
                }
            }

            return input;
        }
    }
}

